﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace msBsc.WebUi.wMall.Seller
{
    public partial class wfDjackRecommend :msBsc.Cls.BPDealer
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        //初始化用户信息
        private void getDjackInfo()
        {
            string djackId = msBsc.SvRef.UserInfo.Operator;
            if (string.IsNullOrEmpty(djackId))
            {
                this.ExecJScript(@"window.location.href = ""/""");
                return;
            }
            using (msBsc.AppLogic.DataAlc.CBizVehicleInfo vehicleInfo = new AppLogic.DataAlc.CBizVehicleInfo())
            {
                DataSet ds = vehicleInfo.SelectByIds(djackId, "");
                if (ds != null)
                {
                    string retJson = msBsc.AppLogic.Cfg.HttpTools.GetJsonByTable(ds.Tables[0], "", "", 1, 50, "");
                    this.ExecJScript(@"setDjackInfo(" + retJson + ")");
                }
            }
        }

        private void saveRecommend() 
        {
            string djackId = msBsc.SvRef.UserInfo.Operator;
            if (string.IsNullOrEmpty(djackId))
            {
                this.ExecJScript(@"window.location.href = ""/""");
                return;
            }
            string recommend = this.GetParamHtValue("userRecommend");
            if (string.IsNullOrEmpty(recommend))
            {
                this.Alert("推荐不能为空");
                return;
            }
            using (msBsc.AppLogic.DataAlc.CBizDjackSpecieInfo specieInfo=new AppLogic.DataAlc.CBizDjackSpecieInfo())
            {
                string[] retArray = specieInfo.AddTravelAdvice(djackId, recommend);
                if (retArray[0]!="TRUE")
                {
                    this.Alert(retArray[1]);
                }
                else
                {
                    this.ExecJScript(@"alert(""编辑旅游推荐成功"");window.location.reload(true);");
                }
            }
        }

        public override void DoAction()
        {
            if (this.strAction=="init")
            {
                getDjackInfo();
            }
            else if (this.strAction=="saveRecommend")
            {
                saveRecommend();
            }
        }
    }
}